#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#

. $(dirname $3)/conf_framework

check() {
    cur_name=$(basename $2)
    config_file_path=$1

    output=0

    if compile_module $cur_name "BLK_MQ_F_STACKING " "linux/blk-mq.h"
    then
        output=1
    fi

    if compile_module $cur_name "BLK_MQ_F_BLOCKING " "linux/blk-mq.h"
    then
        output=$((output+2))
    fi

    echo $cur_name $output >> $config_file_path
}

apply() {
    arg=$1
    if ((arg & 1))
    then
        add_define "CAS_BLK_MQ_F_STACKING \\
            BLK_MQ_F_STACKING"
    else
        add_define "CAS_BLK_MQ_F_STACKING 0"
    fi

    if ((arg & 2))
    then
        add_define "CAS_BLK_MQ_F_BLOCKING \\
            BLK_MQ_F_BLOCKING"
    else
        add_define "CAS_BLK_MQ_F_BLOCKING 0"
    fi
}

conf_run $@
